<template>
	<view class="wx-auth">
		<view class="wx-auth" >
			<view class="header"><image src="../../static/img/logo.png"></image></view>
			<view class="content2">
				<view class="text-size-max">申请获取以下权限</view>
				<text>获得您的公开信息(昵称，头像等)</text>
			</view>
			<view class="bottom">
				<button class="auth" open-type="getUserInfo" lang="zh_CN" @click="bindGetUserInfo">授权登录</button>
			</view>

		</view>
	</view>
</template>

<script>

// import api from '../../utils/api.js';
// import userUtils from '../../utils/userUtils.js';
export default {
	data() {
		return {
			//判断小程序的API，回调，参数，组件等是否在当前版本可用。
			canIUse: uni.canIUse('button.open-type.getUserInfo'),
			bindUserInfo:null,
		};
	},

	methods:{

		bindGetUserInfo(e) {
			console.log("我被点击了")
				this.$mRouter.push({
					route: this.$mRoutesConfig.bindphone,
					query: {
						id: 1
					}
				});
		},
		toPhoneLogin(){
			uni.redirectTo({
				url:'./phonelogin'
			})
		},

		cancle(){
			uni.navigateBack({
				delta:1
			})
		},

		updateMember(){
			if(this.bindUserInfo!=null){
				var member = {
					avatar: this.bindUserInfo.avatarUrl,
					name: this.bindUserInfo.nickName,
					sex: this.bindUserInfo.gender,
					nickName: this.bindUserInfo.nickName
				}
				api.getUpdateMemberInfo(member,res=>{
					if(res.data.code == 200){
						uni.showToast({title: res.data.message})
					}
				})
			}
		},
	}
}
</script>

<style>
/* 微信授权 */

.wx-auth {
	height: calc(100vh);
	width: 100%;
}

.header {
	margin: 50upx 0 50upx 0;
	border-bottom: 1px solid #eee;
	text-align: center;
	width: 100%;
	height: 300rpx;
	line-height: 450rpx;
}

.header image {
	width: 200upx;
	height: 200upx;
}

.content2 {
	padding: 30upx 80upx;
}

.content2 text {
	display: block;
	color: #9d9d9d;
	margin-top: 40rpx;
}

.bottom {
	display: flex;
	flex-direction: row;
	justify-content: center;
	align-items: center;
}

.auth {
	border-radius: 15rpx;
	margin: 70rpx 50rpx 50rpx 50rpx;
	font-size: 35rpx;
	width: 60%;
	background-color: #2c8cf0;
	color: #ffffff;
}

.cancel-login {
	border-radius: 15rpx;
	margin: 70rpx 20rpx 50rpx 50rpx;
	font-size: 35rpx;
	background-color: #eeeeee;
	width: 30%;
}

.phone-login {
	width: 100%;
	justify-content: center;
}

.phone-login-text {
	color: #666666;
	border-bottom: #999999 solid 2upx;
}
</style>
